import { defineStore } from "pinia";
import { getHotSuggestsAPI, getHotCategoryAPI, getHouseListAPI } from '@/services/modules/homeAPI';
const useHomeStore = defineStore('homeStore', {
    state: () => ({
        hotSuggests: [],
        categories: [],
        HouseList: [],
        listPage: 1,
        isLoading: false,
    }),
    actions: {
        /* 获取首页热门城市关键字数据的actions */
        async getHotCityData() {

            //调用getCityAPI接口发请求
            const { data: res } = await getHotSuggestsAPI();
            console.log('getHotSuggestsAPI---', res.data);
            this.hotSuggests = res.data;

        },
        /* 获取首页热门分类数据的actions */
        async getHotCategoryData() {

            //调用getCityAPI接口发请求
            const { data: res } = await getHotCategoryAPI();
            console.log('getHotCategoryAPI---', res.data);
            this.categories = res.data;

        },

        /* 获取首页房间数据的actions */
        async getHouseListData() {

            //调用getCityAPI接口发请求
            const { data: res } = await getHouseListAPI(this.listPage);
            console.log('getHouseListAPI---', this.HouseList);
            this.HouseList.push(...res.data);
            this.listPage++;

        },
    }
})
export default useHomeStore